package com.lkz.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkz.service.IBusinessService;
import com.lkz.entity.Business;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
public class BusinessController {
    @Autowired
    private IBusinessService businessService;
    @GetMapping("/business/businessList")
    public List<Business> customerList(){
        return businessService.list();
    }
    @GetMapping("/business")
    public Map getList(Integer page, Integer limit){
        Map<String,Object> map = new HashMap<String,Object>();
        Page<Business> pages = new Page<Business>();
        pages.setSize(limit);
        pages.setCurrent(page);
        IPage<Business> iPage = businessService.selectList(pages);
        map.put("msg","");
        map.put("count",iPage.getTotal());
        map.put("data",iPage.getRecords());
        map.put("code",0);
        return map;
    }
    @GetMapping("/business/byDel")
    public Map byDel(Integer page, Integer limit){
        Map<String,Object> map = new HashMap<String,Object>();
        Page<Business> pages = new Page<Business>();
        pages.setSize(limit);
        pages.setCurrent(page);
        IPage<Business> iPage = businessService.selectDelList(pages);
        map.put("msg","");
        map.put("count",iPage.getTotal());
        map.put("data",iPage.getRecords());
        map.put("code",0);
        return map;
    }
}
